#!/bin/bash

import tensorflow as tf

# 创建一个变量，初始化为0
state = tf.Variable(0, name="counter")

one = tf.constant(1)
new_value = tf.add(state, one)
update = tf.assign(state, new_value)

# 启动图前，变量必须先由初始化op进行初始化
init_op = tf.initialize_all_variables()

# 启动图，运行op
with tf.Session() as sess:
    sess.run(init_op)
    # 打印初始值
    print(sess.run(state))

    for _ in range(3):
        sess.run(update)
        print ""
